/**
 *
 */

var app = getApp()
Page({
	data: {
		root:'',
		siteroot:app.setting.siteroot,
		att_url:app.setting.att_url,
		account:app.setting.account,
		pagetitle:'红包' + '-' + app.setting.title,
		bannerHeight: Math.ceil(290.0 / 750.0 * getApp().screenWidth)
	},
	onPullDownRefresh: function (){
		var the=this;
		var opt={};
		the.onLoad(opt);
		setTimeout(function(){
			wx.stopPullDownRefresh()
		},1000);
	},
	onLoad: function (options){
		var that = this
		wx.setNavigationBarTitle({'title':that.data.pagetitle});
		var type = options.type
		app.util.get(app.access,function(pagedata){
			//console.log(pagedata);
			that.setData({
				pagedata:pagedata,
				loading:false
			});
			that.get_list(1);
		});
	},
	//翻页
	onReachBottom: function () {
		var isnodata=this.data.isnodata
		var loading=this.data.loading
		if(!isnodata && !loading){
			this.get_list()
		}
	},
	get_list:function(first){
		var the=this;
		var page = the.data.page
		var pagedata=the.data.pagedata
		var isnodata=the.data.isnodata;
		if(first){
			page = 1;
			pagedata.list=[];
			isnodata=false;
		}
		
		var query='page='+page;
		app.util.get('core/member.cash_log/list/'+query,function(res){
			if(res.list.length<2){
				isnodata=true;
			}
			pagedata.list = pagedata.list.concat(res.list)
			page++
			the.setData({
				'pagedata.list':pagedata.list,
				isnodata:isnodata,
				page:page,
				loading:false,
			});
		});
	},
	click:function(evt){
		//用户点击事件 data.func 为方法名，data.params 为调用参数！
		var data=evt.currentTarget.dataset;
		//console.log(evt);
		app.util[data.func](data.params);
	},
})